package com.hxzy.mq;

import com.hxzy.entity.OrderlyDTO;
import lombok.extern.log4j.Log4j2;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author gityyge
 * @Description 消费者 顺序消息，必须保证 线程数只能是1，只允许一个线程进入到队列中
 * @Date 2023/8/10 14:19
 * @Version 1.0
 */
@Component
@Log4j2
@RocketMQMessageListener(topic = "orderly",consumerGroup = "bunorderly",selectorExpression = "bun",
        consumeMode = ConsumeMode.ORDERLY,consumeThreadNumber = 1)
public class OrderlyBunConsumer implements RocketMQListener<OrderlyDTO> {

    @Override
    public void onMessage(OrderlyDTO message) {
        log.info(Thread.currentThread().getId()+","+message.toString());
    }
}
